import { Message } from 'element-ui';
function axiosMessageShow(data) {
  if (data.error_code === 0) {
    Message({
      message: data.error_msg,
      type: 'success'
    })

  } else {
    Message({
      message: data.error_msg,
      type: 'error'
    })
  }
}
function findAssign(data, name, type,sex,patent) {
  let dataArr = [];
  if (name && type && sex && patent) {
    dataArr = data.filter((item) => {
      return item.name.toLowerCase().includes(name.toLowerCase())
        && item.type == type
        && item.sex == sex
        && item.patent == patent 
    })
    return dataArr;
  }
  if (name) {
    dataArr = data.filter((item) => {
      return item.name.toLowerCase().includes(name.toLowerCase())
    })
    return dataArr;
  }
  if (type) {
    dataArr = data.filter((item) => {

      return item.typeid == type
    })
    return dataArr
  }
}

function formtTime(data) {
  const dataPre = new Date(data);

  return `${dataPre.getFullYear()}-${dataPre.getMonth() + 1}-
          ${dataPre.getDate()} ${dataPre.getHours()}:
          ${dataPre.getMinutes()}:${dataPre.getSeconds()}
        `
}
export {
  axiosMessageShow, findAssign, formtTime
}
